package robotleMvc.frameworks.buildEdit
{
	import _Pan3D.base.Object3D;
	import _Pan3D.core.Groundposition;
	
	import _me.Scene_data;
	
	import flash.display.Stage;
	import flash.events.MouseEvent;
	import flash.geom.Vector3D;
	
	import org.robotlegs.mvcs.Mediator;
	
	import robotleMvc.frameworks.build.model.BuildModel;
	import robotleMvc.frameworks.buildEdit.event.BuildEditEvent;
	import robotleMvc.ui.buildEdit.BuildEditView;

	public class BuildEditMediator extends Mediator
	{
		[Inject]
		public var buildEditView:BuildEditView;
		[Inject]
		public var buildModel:BuildModel;

		public function BuildEditMediator()
		{
			super();
		}

		override public function onRegister():void
		{
			initData();
			this.addContentViewListener(buildEditView.buildList, BuildEditEvent.BUILD_EDIT_CELL_CHOOSE, buildEditCellChoose)
			Scene_data.stage.addEventListener(MouseEvent.CLICK, stageClik)
		}

		protected function stageClik(event:MouseEvent):void
		{
			if (event.target as Stage)
			{

			}
			else
			{
				return;
			}
			//var _E : Object3D = Groundposition._getdispxyz(Scene_data.cam3D, Scene_data.stage.mouseX - Scene_data.stage3D.x, Scene_data.stage.mouseY - Scene_data.stage3D.y,0);
		
            
			//buildModel.changeBuildSpritePosition(new Vector3D(_E.x,_E.y,_E.z))
		}

		private function buildEditCellChoose(buildEditEvent:BuildEditEvent):void
		{

			if (buildModel.chooseBuildStatVO && buildModel.chooseBuildStatVO.id == buildEditEvent.chooseStatVO.id)
			{
				buildModel.chooseBuildStatVO=null;
			}
			else
			{
				buildModel.chooseBuildStatVO=buildEditEvent.chooseStatVO
			}

		}

		private function initData():void
		{


			buildEditView.buildList.model.source=buildModel.bulidItem;
		}

		private function buildStatListLoadOk(buildEditEvent:BuildEditEvent):void
		{
			// TODO Auto Generated method stub


		}
	}
}
